package com.one.group.admin.controller;

import com.one.group.admin.service.impl.SpBillServiceImpl;
import com.one.group.enums.ErrorCode;
import com.one.group.model.dto.PayerBillDto;
import com.one.group.model.dto.PayerBillQueryDto;
import com.one.group.model.dto.PayerlistDto;
import com.one.group.model.vo.PayerInfoVo;
import com.one.group.result.Result;
import com.one.group.utils.ResultUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/CheckStandController")
@Tag(name = "收银台相关接口")
public class CheckStandController {
    @Autowired
    private SpBillServiceImpl spBillServiceImpl;
    @PostMapping("/Payerlist")
    @Operation(summary = "查询用户信息")
    public Result Payerlist(@RequestBody PayerlistDto payerlistDto){
        return ResultUtil.success((List<PayerInfoVo>)spBillServiceImpl.Payerlist(payerlistDto));
    }
    @PostMapping("/PayerBillQuery")
    @Operation(summary = "查询用户未支付账单")
    public Result PayerBillQuery(@RequestBody PayerBillQueryDto payerBillQueryDto){
        return ResultUtil.success(spBillServiceImpl.myPayerBillQuery(payerBillQueryDto,0));
    }
    @PostMapping("/PayerBillQueryPaied")
    @Operation(summary = "查询用户已支付账单")
    public Result PayerBillQueryPaied(@RequestBody PayerBillQueryDto payerBillQueryDto){
        return ResultUtil.success(spBillServiceImpl.myPayerBillQuery(payerBillQueryDto,1));
    }
    @PostMapping("/BillPay")
    @Operation(summary = "用户支付账单")
    public Result BillPay(@RequestBody PayerBillDto payerBillDto){
        if (spBillServiceImpl.BillPay(payerBillDto))
            return ResultUtil.success("支付成功");
        else return ResultUtil.error(ErrorCode.OPERATION_ERROR);
    }
}
